package com.ctbu.yyx.cameracontrol.webapi;

import com.ctbu.yyx.cameracontrol.domain.User;
import com.ctbu.yyx.cameracontrol.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.expression.spel.ast.NullLiteral;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/webapi")
public class RegisterRestController{
    @Autowired
    private UserService userService;

    @PostMapping ("/register")
    public int registeruser (User user){

        List<User> users = userService.findByUserName(user.getUserName());
        if(users.size()>0){
            return -1;
        }else{
            User user1 = userService.insert(user);
            return 1;
        }


    }

}
